﻿<Page 
    xmlns:Controls="using:Microsoft.ALMRangers.VsarTreasureMap.WindowsStoreApp.Views.Controls" 
    x:Class="Microsoft.ALMRangers.VsarTreasureMap.WindowsStoreApp.Views.TreasureMapPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Microsoft.ALMRangers.VsarTreasureMap.WindowsStoreApp.Views"
    xmlns:viewmodels="using:Microsoft.ALMRangers.VsarTreasureMap.WindowsStoreApp.ViewModels"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.TopAppBar>
        <AppBar>
            <StackPanel Orientation="Horizontal">
                <Button Command="{Binding GoBack}" Style="{StaticResource AppBarTextButtonStyle}" FontSize="26.667" Margin="40,0,0,0">Back</Button>
            </StackPanel>
        </AppBar>
    </Page.TopAppBar>

    <Grid PointerWheelChanged="ZoomPointerWheelChanged" KeyDown="Grid_KeyDown" KeyUp="Grid_KeyUp" ManipulationMode="Scale" ManipulationDelta="Grid_ManipulationDelta" Background="{StaticResource BackgroundBrush}">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="VisualStateGroup">
                <VisualStateGroup.Transitions>
                    <VisualTransition From="ZoomedIn" GeneratedDuration="0" To="ZoomedOut">
                        <Storyboard>
                            <DoubleAnimation Duration="0:0:0.5" To="0.01" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="ZoomedInGrid" d:IsOptimized="True"/>
                            <DoubleAnimation Duration="0:0:0.5" To="0.01" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="ZoomedInGrid" d:IsOptimized="True"/>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ZoomedInGrid">
                                <DiscreteObjectKeyFrame KeyTime="0:0:0.5">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Collapsed</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="ZoomedOutGrid">
                                <EasingDoubleKeyFrame KeyTime="0" Value="0.01"/>
                                <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="ZoomedOutGrid">
                                <EasingDoubleKeyFrame KeyTime="0" Value="0.01"/>
                                <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ZoomedOutGrid">
                                <DiscreteObjectKeyFrame KeyTime="0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualTransition>
                    <VisualTransition From="ZoomedOut" GeneratedDuration="0" To="ZoomedIn">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ZoomedInGrid">
                                <DiscreteObjectKeyFrame KeyTime="0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="ZoomedInGrid">
                                <EasingDoubleKeyFrame KeyTime="0" Value="0.01"/>
                                <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="ZoomedInGrid">
                                <EasingDoubleKeyFrame KeyTime="0" Value="0.01"/>
                                <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimation Duration="0:0:0.5" To="0.01" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="ZoomedOutGrid" d:IsOptimized="True"/>
                            <DoubleAnimation Duration="0:0:0.5" To="0.01" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="ZoomedOutGrid" d:IsOptimized="True"/>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ZoomedOutGrid">
                                <DiscreteObjectKeyFrame KeyTime="0:0:0.5">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Collapsed</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="ZoomedIn"/>
                <VisualState x:Name="ZoomedOut">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ZoomedOutGrid">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ZoomedInGrid">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="120"/>
                <RowDefinition Height="20"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid Grid.Row="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="140"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="1" Text="ALM Readiness Treasure Map" Style="{StaticResource PageHeaderTextStyle}" Foreground="{StaticResource TitleBrush}" FontFamily="{StaticResource TitleFont}" Margin="0,0,30,0"/>
                <Button Grid.Column="1" Command="{Binding LaunchSearch}" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,40,0" Style="{StaticResource TextButtonStyle}">
                    <TextBlock><Run FontFamily="Segoe UI Symbol" FontSize="24">&#xE11A;</Run><Run FontSize="24" xml:space="preserve"> Search</Run></TextBlock>
                </Button>
            </Grid>
            <Grid Grid.Row="2" x:Name="ZoomedOutGrid" Visibility="Collapsed" RenderTransformOrigin="0.5,0.5">
                <Grid.RenderTransform>
                    <CompositeTransform/>
                </Grid.RenderTransform>
                <Viewbox>
                    <Controls:TreasureMapZoomedOutBackground HorizontalAlignment="Left" VerticalAlignment="Top"/>
                </Viewbox>
            </Grid>
            <Grid Grid.Row="2" x:Name="ZoomedInGrid" RenderTransformOrigin="0.5,0.5">
                <Grid.RenderTransform>
                    <CompositeTransform/>
                </Grid.RenderTransform>
                <Viewbox Stretch="UniformToFill" >
                    <local:TreasureMapBackground Offset="{Binding HorizontalOffset, ElementName=ZoomedInScrollViewer, Mode=OneWay}" />
                </Viewbox>
                <ScrollViewer x:Name="ZoomedInScrollViewer" HorizontalScrollMode="Enabled" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Disabled" VerticalScrollMode="Disabled" ZoomMode="Disabled">
                    <Viewbox>
                        <local:TreasureMapIslands/>
                    </Viewbox>
                </ScrollViewer>
                <Button Grid.Row="2" x:Name="button" HorizontalAlignment="Right" VerticalAlignment="Bottom" Height="18" Width="18" Background="#9B686868" BorderBrush="{x:Null}" BorderThickness="0" Padding="0" Style="{StaticResource ZoomButtonStyle}" Click="ZoomButtonClick">
                    <Path Data="M0,0 L0.5,0" Stretch="Fill" Stroke="Black" UseLayoutRounding="False" StrokeThickness="3"/>
                </Button>
            </Grid>
        </Grid>


    </Grid>
</Page>